﻿<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>添加信息</title>
    <script src="http://www.codefans.net/ajaxjs/jquery-1.6.2.min.js"></script>

</head>
<body>
    <h1 style="text-align:center">添加信息</h1>
    <form method="post" action="/Home/add" enctype="multipart/form-data">
        <table align="center">
            <tr>
                <td>
                    头像:<input type="file" name="image" id="file0" />
                    <img src="" id="img0" />
                </td>
            </tr>
            <tr>
                <td>
                    姓名:<input name="EmpName" type="text" autocomplete="off" />

                </td>
            </tr>
            <tr>
                <td>年龄:<input name="Age" type="text" autocomplete="off" /></td>
            </tr>
            <tr>
                <td>
                    性别:
                    <select name="Sex">
                        <option value="男">男</option>
                        <option value="女">女</option>
                    </select>
            </tr>
            <tr>
                <td>
                    出生年月:<input name="AddTime" type="date" autocomplete="off" />
                </td>
            </tr>
            <tr>
                <td>工资:<input name="Wage" type="text" autocomplete="off" /></td>
            </tr>
            <tr>
                <td>
                    部门:
                    <select name="DepId">
                        <option value="1">人事部</option>
                        <option value="2">产品开发部</option>
                        <option value="3">开发部</option>
                        <option value="4">经理部</option>
                        <option value="5">空运部</option>
                    </select>
                </td>
            </tr>
            <tr style="text-align:center">
                <td>
                    <input type="submit" value="确定" />
                    <input type="button" value="返回" onclick="history.back(-1)" />
                </td>
            </tr>
        </table>
    </form>

    <script>
        $("#file0").change(function () {
            var objUrl = getObjectURL(this.files[0]);
            console.log("objUrl = " + objUrl);
            if (objUrl) {
                $("#img0").attr("src", objUrl).height(70);

            }
        });

        //建立一個可存取到該file的url
        function getObjectURL(file) {
            var url = null;
            if (window.createObjectURL != undefined) {
                url = window.createObjectURL(file);
            } else if (window.URL != undefined) {
                url = window.URL.createObjectURL(file);
            } else if (window.webkitURL != undefined) {
                url = window.webkitURL.createObjectURL(file);
            }
            return url;
        }
    </script>

</body>
</html>
